<?php
class App_Module_Admin_Component_Media_Tpl_List extends App_Module_Admin_Tpl_List
{
	protected $_showCells = array('thumb', 'title', 'icons');
	protected $_emptyListMessage = 'FILES_NOT_FOUND';
	
    public function GetList($ctrlName, $filter, $page)
    {
        $onPage = Mozg_Cfg::Get('admin/media')->GetPerPage();
               
        $paginator = new Mozg_Paginator($page, $onPage);
        $pattern = Mozg::Router('http')->Create('module=admin&ctrl=' .$ctrlName. '&action=list&page=__page__');
        
        $this->ctrlName = $ctrlName;
        
        $icons = array(
        	array(
        	'add' => array(
        					'title' => 'ADD',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$ctrlName. '&action=add')
        					),
        	)
        );
        
        $objects = Mozg_Mapper::Get('Media')->GetList($filter, $paginator);
        $paginator->SetTotalCount(Mozg_Mapper::Get('Media')->GetTotalRows());
        $content = $this->CreateList($objects, $paginator, $pattern);
        
        return $this->GetTpl('Base')->LoadTemplate(Mozg_Lang::_('MEDIA_FILES'), $content, $icons);
    }

	protected function GetCellThumb($obj)
	{
		$this->thumbFolder = Mozg_Mapper::Get('Image')->GetImageThumbFolder('mediathumbnail');
		$this->obj = $obj;
		return $this->render('media/list/_thumb.phtml');
	}
    
	protected function GetCellTitle($obj)
	{
		$this->obj = $obj;
		return $this->render('media/list/_title.phtml');
	}
	
	protected function GetCellIcons($obj)
	{
        $icons = array(
        	'edit' => array(
        					'title' => 'EDIT',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=add&id=' .$obj->GetId())
        					),

        	'delete' => array(
        					'title' => 'DELETE_MEDIA_FILE?',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=del&id=' .$obj->GetId())
        					),

        );
		return $this->GetTpl('Icon')->GetIconSet($icons, 'list');
	}
}